Generated by Cython 3.0.2
Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.
Raw output: math.c
+01: # cython: infer_types=True, wraparound=False, nonecheck=False, boundscheck=False, cdivision=True, language_level=3, profile=True, autogen_pxd=True
__pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
02:
03: from libc.math cimport sqrt, pi
04:
+05: def get_sine(angle: float, cos_a: float):
/* Python wrapper */
static PyObject *__pyx_pw_7nanopyx_4core_5utils_4math_1get_sine(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_7nanopyx_4core_5utils_4math_1get_sine = {"get_sine", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7nanopyx_4core_5utils_4math_1get_sine, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7nanopyx_4core_5utils_4math_1get_sine(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
double __pyx_v_angle;
double __pyx_v_cos_a;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("get_sine (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args);
if (unlikely((__pyx_nargs < 0))) __PYX_ERR(0, 5, __pyx_L3_error)
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_angle,&__pyx_n_s_cos_a,0};
PyObject* values[2] = {0,0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_angle)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cos_a)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5, __pyx_L3_error)
else {
__Pyx_RaiseArgtupleInvalid("get_sine", 1, 2, 2, 1); __PYX_ERR(0, 5, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_sine") < 0)) __PYX_ERR(0, 5, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 2)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
}
__pyx_v_angle = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_angle == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 5, __pyx_L3_error)
__pyx_v_cos_a = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_cos_a == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 5, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("get_sine", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 5, __pyx_L3_error)
goto __pyx_L3_error;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("nanopyx.core.utils.math.get_sine", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_7nanopyx_4core_5utils_4math_get_sine(__pyx_self, __pyx_v_angle, __pyx_v_cos_a);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_7nanopyx_4core_5utils_4math_get_sine(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_angle, double __pyx_v_cos_a) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj_)
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("get_sine", 0);
__Pyx_TraceCall("get_sine", __pyx_f[0], 5, 0, __PYX_ERR(0, 5, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("nanopyx.core.utils.math.get_sine", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__2 = PyTuple_Pack(2, __pyx_n_s_angle, __pyx_n_s_cos_a); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__2);
__Pyx_GIVEREF(__pyx_tuple__2);
/* … */
__pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_angle, __pyx_n_s_float) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_cos_a, __pyx_n_s_float) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_7nanopyx_4core_5utils_4math_1get_sine, 0, __pyx_n_s_get_sine, NULL, __pyx_n_s_nanopyx_core_utils_math, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_CyFunction_SetAnnotationsDict(__pyx_t_3, __pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_sine, __pyx_t_3) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+06: return _get_sine(angle, cos_a)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_7nanopyx_4core_5utils_4math__get_sine(__pyx_v_angle, __pyx_v_cos_a); if (unlikely(__pyx_t_1 == ((float)-1) && PyErr_Occurred())) __PYX_ERR(0, 6, __pyx_L1_error) __pyx_t_2 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
07:
+08: cdef float _get_sine(float angle, float cos_a) nogil:
static float __pyx_f_7nanopyx_4core_5utils_4math__get_sine(float __pyx_v_angle, float __pyx_v_cos_a) {
float __pyx_r;
__Pyx_TraceDeclarations
__Pyx_TraceCall("_get_sine", __pyx_f[0], 8, 1, __PYX_ERR(0, 8, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_L1_error:;
#ifdef WITH_THREAD
__pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("nanopyx.core.utils.math._get_sine", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
__pyx_L0:;
__Pyx_TraceReturn(Py_None, 1);
return __pyx_r;
}
+09: if angle > pi:
__pyx_t_1 = (__pyx_v_angle > M_PI);
if (__pyx_t_1) {
/* … */
}
+10: return sqrt(1 - (cos_a * cos_a)) * -1
__pyx_r = (sqrt((1.0 - (__pyx_v_cos_a * __pyx_v_cos_a))) * -1.0);
goto __pyx_L0;
11: else:
+12: return sqrt(1 - (cos_a * cos_a))
/*else*/ {
__pyx_r = sqrt((1.0 - (__pyx_v_cos_a * __pyx_v_cos_a)));
goto __pyx_L0;
}